# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=rime-wubi
pkgver=0.0.0.20231025
_commit=152a0d3f3efe40cae216d1e3b338242446848d07
pkgrel=1
pkgdesc="Wubi input for rime"
arch=('loong64' 'x86_64')
url="https://github.com/rime/rime-wubi"
license=('LGPL')
# dependency for reverse lookup
depends=('rime-pinyin-simp')
makedepends=('librime' 'rime-prelude' 'rime-essay')
source=("https://github.com/rime/rime-wubi/archive/$_commit/rime-wubi-$_commit.tar.gz")
sha512sums=('f535a15f1a52b7173b42d72fec58cbb68887be590cee1a2a6b1d883dec377d61cf17ece68f0c400dec26b55fd0ac2744d0fb835d8c9129245ddc985fa256ebb8')

prepare() {
  cd $pkgname-$_commit
  # Link essentials
  for _f in $(pacman -Qql rime-prelude rime-essay | grep -v "/$"); do ln -sf $_f; done
}

build(){
  cd $pkgname-$_commit
  for _s in $(ls *.schema.yaml); do rime_deployer --compile $_s; done
}

package() {
  cd $pkgname-$_commit
  find . -type l -delete
  rm build/*.txt
  install -Dm644 *.yaml -t "$pkgdir"/usr/share/rime-data/
  install -Dm644 build/* -t "$pkgdir"/usr/share/rime-data/build/
}
